package com.stx.Serialization;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class test {
    public static void main(String[] args) {
        User user = new User("zhangsan","10086",26);

        //序列化存到文件中
        try{
            //创建一个文件，将后续序列化的数据保存到里面
            FileOutputStream fops = new FileOutputStream("D:\\download\\user");
            //序列化
            ObjectOutputStream oos = new ObjectOutputStream(fops);

            oos.writeObject(user);
        }catch (Exception e){
            System.out.println(e);
//            e.printStackTrace();
        }


    }
}
